package com.example.tellwin.view;

import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.example.tellwin.R;
import com.example.tellwin.base.BaseDialog;

/**
 * @author : LinZePeng
 * @date : 2020/11/18
 * @Describe ：
 **/
public class ConfirmDialog extends BaseDialog {


    private TextView contentTv;
    private TextView cancelBtn;
    private TextView confrimBtn;

    private String content;
    private OnConfrimClickListener onConfrimClickListener;


    public ConfirmDialog(@NonNull Context context , String content ,OnConfrimClickListener onConfrimClickListener) {
        super(context, R.style.ActionSheetDialogStyle);
        this.content = content;
        this.onConfrimClickListener = onConfrimClickListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_confirm);
        initView();
        initEvents();
        initData();
    }

    private void initView() {
        contentTv = (TextView) findViewById(R.id.content_tv);
        cancelBtn = (TextView) findViewById(R.id.cancel_btn);
        confrimBtn = (TextView) findViewById(R.id.confrim_btn);
    }

    private void initEvents(){
        confrimBtn.setOnClickListener(v -> {
            onConfrimClickListener.onConfrimClick();
            dismiss();
        });
        cancelBtn.setOnClickListener(v -> dismiss());
    }
    private void initData(){
        contentTv.setText(content);
    }

    public interface OnConfrimClickListener{
        void onConfrimClick();
    }
}
